import org.junit.Assert;
import org.junit.Test;

import java.io.IOException;
import java.net.URISyntaxException;

public class 测试字节码汇编器 {

    private void 测试(String 文件名, String 结尾字符串) throws IOException, URISyntaxException {
        var 源码 = Tools.读文件(Tools.getResourcePath(文件名));
        var 汇编器 = 字节码汇编器.汇编(源码);
        var 字节码输出 = 字节码汇编器.输出字节码(汇编器.字节码, 汇编器.取字节码尺寸());
        System.out.println(字节码输出);
        Assert.assertTrue(字节码输出.endsWith(结尾字符串));
    }

    @Test
    public void 测试T0() throws IOException, URISyntaxException {
        测试("t.rcode", "0048:   0   3  29\r\n");
    }

    @Test
    public void 测试T2() throws IOException, URISyntaxException {
        测试("t2.rcode", "0072:  29\r\n");
    }

    @Test
    public void 测试T3() throws IOException, URISyntaxException {
        测试("t3.rcode", "0064:   0  29\r\n");
    }

    @Test
    public void 测试T4() throws IOException, URISyntaxException {
        测试("t4.rcode", "0072:   0   2   0   0   0   0  13\r\n");
    }

    @Test
    public void 测试Struct() throws IOException, URISyntaxException {
        测试("struct.rcode", "0088:   0  26   0   0   0   2  29\r\n");
    }
}
